﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using Medianamik.Core.Security;
using System.Globalization;
using Medianamik.Core.Interfaces;
using Medianamik.Core.Urls;

namespace Medianamik.Core.DAL
{
    public interface IConfigDALProvider
    {

        #region DataTypes

        List<DataType> GetAllDataTypes();

        DataType GetDataTypeById(Guid pDataTypeId);

        #endregion

        #region Culture

        IEnumerable<Culture> GetEditionCultures();

        IEnumerable<Culture> GetMedianamikCultures();

        IEnumerable<Culture> GetAllCultures();

        Culture SaveCulture(Culture pCulture);

        #endregion

        #region Medianamik Control

        List<MedianamikControl> GetMedianamikControls(Guid? pDataTypeId, MedianamikControlType? pControlType);

        MedianamikControl GetMedianamikControl(Guid pMedianamikControlID);

        void DeleteMedianamikControl(Guid controlId);

        MedianamikControl SaveMedianamikControl(MedianamikControl control);

        #endregion

        #region Logging

        // le type est optionel; par défaut, il vaut LogEntryType.Node
        void LogActivity(Guid? pObjectId, string pObjectName, string pUserName, string pMessage, string pIP, string pUserAgent);
        void LogActivity(Guid? pObjectId, string pObjectName, string pUserName, string pMessage, string pIP, string pUserAgent, Logging.LogEntryType pType);

        List<Logging.ILogEntry> GetLogEntries(int pageIndex, int count);
        List<Logging.ILogEntry> GetLogEntries(int pageIndex, int count, IDictionary<string, object> condition);

        int CountLogEntries();
        int CountLogEntries(IDictionary<string, object> condition);

        void PurgeLogEntries();
        void PurgeLogEntries(IDictionary<string, object> condition);

        #endregion

        #region Locks

        void DestroyLockByObjectId(Guid pObjectId);
        void DestroyLockByLockId(Guid pLockId);
        ILock CreateLock(Guid pTransacId, Guid pObjectId, TimeSpan pUltimatum, string pUserName);
        void UpdateLock(Guid pLockId, DateTime pActivationDate, DateTime pLastCall);
        ILock[] GetLocksByObjectId(Guid pObjectId);
        ILock[] GetLocks(int pPageIndex, int pPageSize);

        #endregion

        #region Urls

        //List<UrlXmlDoc> GetUrlXmlDocs();
        //List<UrlXmlDoc> GetUrlXmlDocs(Guid pNodeId); 

        #endregion

        #region Database Versioning

        List<ISchemaChange> GetSchemaChangesApplied();

        void ApplySchemaChange(string pSchemaChangeSql);
        void InsertSchemaChange(ISchemaChange pSchemaChange);


        #endregion

        #region Configurations

        IDictionary<String, String> GetAllConfigurations();

        void SaveConfiguration(String key, string value);

        #endregion

        void RefreshUrlDictionary();
    }
}
